from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QTableWidgetItem
from classes.engine import Engine
from ui_py.form_ui import Ui_Form
from PyQt5 import QtCore, QtGui, QtPrintSupport, QtWidgets
from datetime import datetime
from temp import ReadExcel
import glob
from datetime import datetime, date
from dataExpert import Data
from expert import Expert
from validation import validation
import numpy as np
from pypdf import PdfMerger
import os
import shutil
from report import OpenReport

def data_upper_lower_hmin(data, angles):
        res = [0]*2
        vals_270_90 = []
        vals_90_270 = []
        # for i in range(len(data)):
        #     if 0<=i<90 or 270<i<450:
        #         vals_270_90.append(data[i])
        #     else:
        #         vals_90_270.append(data[i])
        # print(len(data), len(angles))
        for ind, angle in enumerate(angles):
            if 0<=angle<90 or 270<angle<450:
                # print(ind, angle, data[ind])
                vals_270_90.append(data[ind])
            else:
                # print(ind, angle, data[ind])
                vals_90_270.append(data[ind])
        if not vals_270_90 == []:
            res[0] = min(vals_270_90)
        if not vals_90_270 == []:
            res[1] = min(vals_90_270)

        # print(res)
        return res

def data_upper_lower_dm(data, angles):
        res = [0]*2
        vals_270_90 = []
        vals_90_270 = []
        # for i in range(len(data)):
        #     if 0<=i<90 or 270<i<450:
        #         vals_270_90.append(data[i])
        #     else:
        #         vals_90_270.append(data[i])

        for ind, angle in enumerate(angles):
            if 0<=angle<90 or 270<angle<450:
                vals_270_90.append(data[ind])
            else:
                vals_90_270.append(data[ind])

        if not vals_270_90 == []:
            res[0] = max(vals_270_90)
        if not vals_90_270 == []:
            res[1] = max(vals_90_270)
        
        return res

class Form(QtWidgets.QWidget, Ui_Form):
    engine = Engine()
    def __init__(self):
        # self.dict_from_excel = dict_excel
        self.expert = Expert()
        self.open_report = OpenReport()
        self.first = 0
        self.Mode = 0
        self.dict_engine = {
            1: "L4",
            2: "L6",
            3: "V8",
            4: "L3",
            5: "V6",
            6: "V12"
        }
        # self.filename = file_name
        time = str(datetime.now().time())
        self.data = Data()
        # if sorted(self.expert.modes)[0] == 2:
        # self.first = 1
        # self.Mode = 1
        try:self.mode1 = PDF(glob.glob('data/mode1/*.xlsx')[0], self.expert.dict_mode1, self.data.wm1, time, 1)
        except:pass
        try:self.mode2 = PDF(glob.glob('data/mode2/*.xlsx')[0], self.expert.dict_mode2, self.data.wm2, time, 2)
        except:pass
        try:self.mode3 = PDF(glob.glob('data/mode3/*.xlsx')[0], self.expert.dict_mode3, self.data.wm3, time, 3)
        except:pass
        # if sorted(self.expert.modes)[0] == 3:
        #     # if self.first == 0:
        #     #     self.first = 2
        #     #     self.Mode = 2
        #     try:
        #         self.mode2 = PDF(glob.glob('data/mode2/*.xlsx')[0], self.expert.dict_mode2, time)
        #     except:
        #         pass
        #     try:
        #         self.mode1 = PDF(glob.glob('data/mode1/*.xlsx')[0], self.expert.dict_mode1, time)
        #     except:
        #         pass
        #     try:
        #         self.mode3 = PDF(glob.glob('data/mode3/*.xlsx')[0], self.expert.dict_mode3, time)
        #     except:
        #         pass
        # if sorted(self.expert.modes)[0] == 4:
        #     # if self.first == 0:
        #     #     self.first = 3
        #     #     self.Mode = 3
        #     self.mode3 = PDF(glob.glob('data/mode3/*.xlsx')[0], self.expert.dict_mode3, time)
        #     try:
        #         self.mode1 = PDF(glob.glob('data/mode1/*.xlsx')[0], self.expert.dict_mode1, time)
        #     except:
        #         pass
        #     try:
        #         self.mode2 = PDF(glob.glob('data/mode2/*.xlsx')[0], self.expert.dict_mode2, time)
        #     except:
        #         pass

        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)
        self.engine = self.engine.cil
        # self.comboBox.blockSignals(True)
        self.comboBox.addItem("Выберите")
        self.comboBox.setCurrentText("Выберите")
        self.comboBox_2.addItem("Выберите")
        self.comboBox_2.setCurrentText("Выберите")
        self.comboBox_3.addItem("Выберите")
        self.comboBox_3.setCurrentText("Выберите")
        # self.comboBox.blockSignals(False)
        # match self.first:
        #     case 1:
        #         self.pdf = self.mode1
        #     case 2:
        #         self.pdf = self.mode2
        #     case 3:
        #         self.pdf = self.mode3
        self.comboBox_3.currentIndexChanged.connect(self.takt)
        self.comboBox_2.currentIndexChanged.connect(self.application)
        self.pushButton.clicked.connect(self.send_report)
        self.comboBox.currentIndexChanged.connect(self.turbo)
        self.lineEdit_2.textChanged.connect(self.litrag)
        self.lineEdit_4.textChanged.connect(self.fio)
        self.lineEdit_5.textChanged.connect(self.model_engine)
    def takt(self, index):
        try:self.mode1.dict['takt'] = self.comboBox_3.itemText(index)
        except:pass
        try:self.mode2.dict['takt'] = self.comboBox_3.itemText(index)
        except:pass
        try:self.mode3.dict['takt'] = self.comboBox_3.itemText(index)
        except:pass
    def litrag(self):
        try:self.mode1.dict['litrag'] = self.lineEdit_2.text()
        except:pass
        try:self.mode2.dict['litrag'] = self.lineEdit_2.text()
        except:pass
        try:self.mode3.dict['litrag'] = self.lineEdit_2.text()
        except:pass
    def application(self, index):
        try:self.mode1.dict['application'] = self.comboBox_2.itemText(index)
        except:pass
        try:self.mode2.dict['application'] = self.comboBox_2.itemText(index)
        except:pass
        try:self.mode3.dict['application'] = self.comboBox_2.itemText(index)
        except:pass
    def fio(self):
        try:self.mode1.dict['fio'] = self.lineEdit_4.text()
        except:pass
        try:self.mode2.dict['fio'] = self.lineEdit_4.text()
        except:pass
        try:self.mode3.dict['fio'] = self.lineEdit_4.text()
        except:pass
    def turbo(self, index):
        try:self.mode1.dict['turbo'] = self.comboBox.itemText(index)
        except:pass
        try:self.mode2.dict['turbo'] = self.comboBox.itemText(index)
        except:pass
        try:self.mode3.dict['turbo'] = self.comboBox.itemText(index)
        except:pass
    def model_engine(self):
        try:self.mode1.dict['model_engine'] = self.lineEdit_5.text()
        except:pass
        try:self.mode2.dict['model_engine'] = self.lineEdit_5.text()
        except:pass
        try:self.mode3.dict['model_engine'] = self.lineEdit_5.text()
        except:pass
    def send_report(self):
        if self.engine == "L3" or self.engine == "V6":
            try:
                self.mode1.add_begining_row_to_table(self.mode1.dict)
            except:pass
            try:
                self.mode1.create_l3_v6_pdf()
            except:pass
            try:
                self.mode2.add_begining_row_to_table(self.mode2.dict)
            except:pass
            try:
                self.mode2.create_l3_v6_pdf()
            except:pass
            try:
                self.mode3.add_begining_row_to_table(self.mode3.dict)
            except:pass
            try:
                self.mode3.create_l3_v6_pdf()
            except:pass
        elif self.engine == "L4" or self.engine == "V8":
            try:
                self.mode1.add_begining_row_to_table(self.mode1.dict)
            except:pass
            try:
                self.mode1.create_l4_v8_pdf()
            except:pass
            try:
                self.mode2.add_begining_row_to_table(self.mode2.dict)
            except:pass
            try:
                self.mode2.create_l4_v8_pdf()
            except:pass
            try:
                self.mode3.add_begining_row_to_table(self.mode3.dict)
            except:pass
            try:
                self.mode3.create_l4_v8_pdf()
            except:pass
        elif self.engine == "L6" or self.engine == "V12":
            try:
                self.mode1.add_begining_row_to_table(self.mode1.dict)
            except:pass
            # try:
            self.mode1.create_l6_v12_pdf()
            # except:pass
            try:
                self.mode2.add_begining_row_to_table(self.mode2.dict)
            except:pass
            try:
                self.mode2.create_l6_v12_pdf()
            except:pass
            try:self.mode3.add_begining_row_to_table(self.mode3.dict)
            except:pass
            try:self.mode3.create_l6_v12_pdf()
            except:pass
        try:self.mode1.save('data/mode1.pdf')
        except:pass
        try:self.mode2.save('data/mode2.pdf')
        except:pass
        try:self.mode3.save('data/mode3.pdf')
        except:pass
        try:
            pdfs = ['data/test.pdf', 'data/mode1.pdf', 'data/mode2.pdf', 'data/mode3.pdf']
            merger = PdfMerger()
            for pdf in pdfs:
                try:
                    merger.append(pdf)
                except:
                    pass
            if len(merger.pages):
                merger.write('data/report.pdf')
            merger.close()
        except:pass
        try:
            os.remove('data/mode1.pdf')
            os.remove('data/mode2.pdf')
            os.remove('data/mode3.pdf')
        except:pass
        if self.expert.from_file:
            shutil.copytree('data', self.data.extern_file, dirs_exist_ok=True)
        self.open_report.show()
        self.close()
# app = QtWidgets.QApplication([])

class PDF:
    def __init__(self, path_to_res, dictionary, wm_dict, time, mode):
        # self.data = Data()
        # if 'mode1' in path_to_res:
        #     self.data.current_mode == 2
        # elif 'mode2' in path_to_res:
        #     self.data.current_mode == 3
        # elif 'mode3' in path_to_res:
        #     self.data.current_mode == 4
        self.wm_dict = wm_dict
        self.mode = mode
        self.engine = Engine()
        self.expert = Expert()
        self.excel = ReadExcel(path_to_res).getAllLists()
        self.Excel = ReadExcel(path_to_res)
        self.dict = {}
        self.t = time
        self.dict_mode = dictionary
        self.grv = {
            0: "NO",
            1: "FULL",
            2: "PART",
            3: "PART"
        }
        self.ms = {
            8: "SAE20",
            10: "SAE30",
            12: "SAE40",
            16: "SAE50"
        }
        if self.engine.cil == "L3":
            self.iwar = {
                1: "1-3-2",
                2: "1-2-3"
            }
        elif self.engine.cil == "L4":
            self.iwar = {
                1: "1-2-4-3",
                2: "1-3-4-2"
            }
        elif self.engine.cil == "L6":
            self.iwar = {
                1: "1-5-3-6-2-4",
                2: "1-4-2-6-3-5"
            }
        elif self.engine.cil == "V6":
            self.iwar = {
                1: "1-4-2-5-3-6",
                2: "1-6-3-5-2-4"
            }
        elif self.engine.cil == "V8":
            self.iwar = {
                1: "1-5-4-2-6-3-7-8",
                2: "1-5-7-2-6-3-4-8",
                3: "1-8-7-2-6-5-4-3"
            }
        elif self.engine.cil == "V12":
            self.iwar = {
                1: "1-12-5-8-3-10-6-7-2-11-4-9",
                2: "1-7-5-11-3-9-6-12-2-8-4-10"
            }
        self.data = Data()
        self.doc = QtGui.QTextDocument()
        self.printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.PrinterResolution)
        self.printer.setOutputFormat(QtPrintSupport.QPrinter.PdfFormat)
        self.printer.setPaperSize(QtPrintSupport.QPrinter.A4)
        self.printer.setOrientation(QtPrintSupport.QPrinter.Landscape)
        self.html = """<html>
                        <head>
                            <style>
                                p{
                                    font-size: 12px;
                                    font-weight: 200;
                                    color: black;
                                }
                                .title{
                                    font-size: 15px;
                                    text-align: center;
                                    font-weight: 700;
                                }

                                .info{
                                    margin: 20px;
                                }
                        
                                table.iksweb{
                                    width: 100%;
                                    border-collapse:collapse;
                                    border-spacing:0;
                                    height: auto;
                                }
                                table.iksweb,table.iksweb td, table.iksweb th {
                                    border: 1px solid #595959;
                                }
                                table.iksweb td,table.iksweb th {
                                    width: 30px;
                                    height: 35px;
                                }
                                table.iksweb th {
                                    background: #347c99; 
                                    color: #fff; 
                                    font-weight: normal;
                                }

                                td {
                                    border: 1px solid black;
                                    text-align: center;
                                }

                                td.wide {
                                    padding:0px 10px 0px 10px;
                                    white-space:nowrap;

                                }

                                td.wide1 {
                                    white-space:nowrap;
                                    padding:2px 1px 2px 2px;
                                }

                                td.wide2 {
                                    white-space:nowrap;
                                    padding:2px 1px 2px 1px;
                                }
                                

                        </style>
                        </head>
                    """
    def save(self, filename):
        self.html+="</table>"
        self.printer.setOutputFileName(filename)
        self.doc.setHtml(self.html)
        self.doc.setPageSize(QtCore.QSizeF(self.printer.pageRect().size()))
        self.doc.print_(self.printer)

    def create_dict(str):
        dictionary = {}

        # dictionary[self.excel.]


    def add_begining_row_to_table(self, data: dict[str, str]):
        if not 'turbo' in data:
            data['turbo'] = '-'
        if not 'takt' in data:
            data['takt'] = '-'
        if not 'litrag' in data:
            data['litrag'] = '-'
        if not 'fio' in data:
            data['fio'] = '-'
        if not 'model_engine' in data:
            data['model_engine'] = '-'
        if not 'application' in data:
            data['application'] = '-'
        nn = self.dict_mode['nn']
        time = self.t
        fuel = "PETROL" if self.excel['kd'] == 1 else "DIESEL"
        time = time[:time.rfind(".")]
        self.html += "<table style=\"width: 100%;border-collapse:collapse;border-spacing:0;height: auto;\">"
        self.html += "<tr><td colspan=\"32\">BEARINGS SUMMARY RESULT</td></tr>"
        self.html += f"<tr><td colspan=\"6\">{str(date.today())}</td><td colspan=\"5\">{time}</td><td colspan=\"7\">{data['fio']}</td><td colspan=\"14\"></td></tr>"
        self.html += "<tr><td colspan=\"5\"></td><td colspan=\"4\"></td><td colspan=\"21\"></td><td colspan=\"2\">Ver.1</td></tr>"
        self.html += f"""<tr><td colspan=\"4\">ENGINE</td>
        <td colspan=\"4\">{data['model_engine']}</td>
        <td colspan=\"3\">FUEL</td>
        <td colspan=\"5\">{fuel}</td>
        <td colspan=\"5\">MAX.CYL.PRESSURE (MPa)</td>
        <td colspan=\"4\">{max(self.Excel.getPIND())}</td>
        <td colspan=\"3\">APPLICATION</td>
        <td colspan=\"4\">{data['application']}</td>
        </tr>"""
        self.html += f"""<tr><td colspan=\"4\">VOL (L)</td>
        <td colspan=\"4\">{data['litrag']}</td>
        <td colspan=\"3\">TYPE</td>
        <td colspan=\"5\">{self.engine.cil}</td>
        <td colspan=\"5\">OIL SUPPLY PRESSURE (MPa)</td>
        <td colspan=\"4\">{self.dict_mode['pm1']}</td>
        <td colspan=\"3\">{data['turbo']}</td>
        <td colspan=\"4\">TC</td></tr>"""
        self.html += f"""<tr><td colspan=\"4\">SPEED (rpm)</td>
        <td colspan=\"4\">{nn}</td>
        <td colspan=\"4\">BORE (mm)</td>
        <td colspan=\"4\">{self.data.excel['DZ']}</td>
        <td colspan=\"16\"></td></tr>"""
        self.html += f"""<tr><td colspan=\"4\">FIRING</td>
        <td colspan=\"7\">{self.iwar[self.data.excel['iwar']]}</td>
        <td colspan=\"21\"></td></tr>"""
    
    def add_headers_from_second_block(self):
        # self.html += "<table>"
        self.html += "<tr>"
        self.html += f"<td colspan=\"2\" rowspan=\"2\">BRG\nNo.</td>"
        self.html += f"<td colspan=\"2\" rowspan=\"2\">DIA\nmm</td>"
        self.html += f"<td colspan=\"4\" rowspan=\"2\">WIDTH\nmm</td>"
        self.html += f"<td colspan=\"2\" rowspan=\"2\">CLEA\nmm</td>"
        self.html += f"<td colspan=\"4\" rowspan=\"2\">GRV</td>"
        self.html += f"<td colspan=\"4\" rowspan=\"2\">GRV\nWIDTH\nmm</td>"
        self.html += f"<td colspan=\"2\" rowspan=\"2\">VISKO.\nmPas</td>"
        self.html += f"<td colspan=\"2\">SP LOAD\nMPa</td>"
        self.html += f"<td colspan=\"2\">Hmin Upper\nmicron</td>"
        self.html += f"<td colspan=\"2\">Hmin Lower\nmicron</td>"
        self.html += f"<td colspan=\"2\">Pmax Upper\nMPa</td>"
        self.html += f"<td colspan=\"2\">Pmax Lower\nMPa</td>"
        self.html += f"<td colspan=\"2\" rowspan=\"2\">Loss\nkW</td>"
        self.html += f"</tr><tr>"
        self.html += f"<td>CA</td><td>BA</td>"
        self.html += f"<td>CA</td><td>BA</td>"
        self.html += f"<td>CA</td><td>BA</td>"
        self.html += f"<td>CA</td><td>BA</td>"
        self.html += f"<td>CA</td><td>BA</td>"


    def add_2_row_in_main_block(self, data_2_row_left, data, angle, Loss, left_header):
        self.html += "<tr>"
        self.html += f"<td class='wide' colspan=\"2\" rowspan=\"2\">{left_header}</td>"

        for i in range(len(data_2_row_left)):
            if i == 1 or i == 3 or i == 4:
                self.html += f"<td class='wide' colspan=\"4\" rowspan=\"2\">{data_2_row_left[i]}</td>"
            elif i == 0:
                if len(str(data_2_row_left[i])) <= 2:
                    self.html += f"<td class='wide' colspan=\"2\" rowspan=\"2\">{data_2_row_left[i]}</td>"
                else:
                    self.html += f"<td class='wide2' colspan=\"2\" rowspan=\"2\">{data_2_row_left[i]}</td>"
            else:
                self.html += f"<td class='wide' colspan=\"2\" rowspan=\"2\">{data_2_row_left[i]}</td>"
        
        for i in range(len(data)):
            self.html += f"<td class='wide' colspan=\"2\">{data[i]}</td>"
        self.html += f"<td class='wide' colspan=\"2\" rowspan=\"2\">{Loss}</td>"
        self.html += "</tr><tr>"

        for i in range(len(angle)):
            self.html += f"<td class='wide1'>{angle[i]}</td>"


        self.html += "</tr>"

    def data_row_BE(self):
        lst = []
        lst.append(self.excel['dsch'])
        lst.append(self.excel['bsch'])
        lst.append(self.excel['ssch'])
        lst.append('NO')
        lst.append('-')
        try:lst.append("{:.2f}".format(self.wm_dict[0] * 1000))
        except:pass
        return lst

    def data_row_MN1(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor1'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan1'])
        try:lst.append("{:.2f}".format(self.wm_dict[1] * 1000))
        except:pass
        return lst
        
    def data_row_MN2(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor2'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan2'])
        try:lst.append("{:.2f}".format(self.wm_dict[2] * 1000))
        except:pass
        return lst

    def data_row_MN3(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor3'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan3'])
        try:lst.append("{:.2f}".format(self.wm_dict[3] * 1000))
        except:pass
        return lst

    def data_row_MN4(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor4'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan4'])
        try:lst.append("{:.2f}".format(self.wm_dict[4] * 1000))
        except:pass
        return lst

    def data_row_MN5(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor5'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan5'])
        try:lst.append("{:.2f}".format(self.wm_dict[5] * 1000))
        except:pass
        return lst

    def data_row_MN6(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor6'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan6'])
        try:lst.append("{:.2f}".format(self.wm_dict[6] * 1000))
        except:pass
        return lst

    def data_row_MN7(self):
        lst = []
        lst.append(self.excel['dkor'])
        lst.append(self.excel['bkor7'])
        lst.append(self.excel['skor'])
        grv = self.data.groove if self.data.groove != "" else self.grv[self.data.excel['nw']]
        lst.append(grv)
        lst.append(self.excel['bkan7'])
        try:lst.append("{:.2f}".format(self.wm_dict[7] * 1000))
        except:pass
        return lst

    def data_BE(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[0]
            and data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[1]
            and data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN1(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM1()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[0]
            and data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[1]
            and data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN2(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM2()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[0]
            and data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[1]
            and data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN3(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM3()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[0]
            and data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[1]
            and data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[1], 2)))
        else:
            lst.append('-')
        return lst
    

    def data_MN4(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM4()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[0]
            and data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[1]
            and data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN5(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM5()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[0]
            and data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[1]
            and data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN6(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM6()), 2)))
        if (data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[1]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[1])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[0]
            and data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[1]
            and data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[1], 2)))
        else:
            lst.append('-')
        return lst
    
    def data_MN7(self):
        lst = []
        lst.append("{:.2f}".format(round(max(self.Excel.PSUM7()), 2)))
        # print("HMIN7")
        # print(data_upper_lower_hmin(self.Excel.hmin7()))
        # print(round(data_upper_lower_hmin(self.Excel.hmin7())[0], 2))
        if (data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[0]
            and ((self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[0]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[0]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[0])))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[0], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[1]
            and (self.mode == 1
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[1]))
            or (self.mode == 2
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[1]))
            or (self.mode == 3
                and (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[1]))
           ):
            lst.append("{:.2f}".format(round(data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[1], 5) * 1000))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[0]
            and data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[0]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[0], 2)))
        else:
            lst.append('-')
        if (data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[1]
            and data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[1]):
            lst.append("{:.2f}".format(round(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[1], 2)))
        else:
            lst.append('-')
        return lst

    def angle_BE(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM())[self.Excel.PSUM().index(max(self.Excel.PSUM()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA())[self.Excel.PSUM().index(max(self.Excel.PSUM()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')

        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt_mode1[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[0])], 2)))

            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt_mode2[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[0])], 2)))

            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt_mode3[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[0])], 2)))
                
            lst.append("{:.2f}".format(round((self.Excel.FHMIN())[self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                print(len(self.data.ugwt_mode1))
                lst.append("{:.2f}".format(round(self.data.ugwt_mode1[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode1[1440:])[1])], 2)))

            elif (self.mode == 2):
                print(len(self.data.ugwt_mode2))
                lst.append("{:.2f}".format(round(self.data.ugwt_mode2[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode2[1440:])[1])], 2)))

            elif (self.mode == 3):
                print(len(self.data.ugwt_mode3))
                lst.append("{:.2f}".format(round(self.data.ugwt_mode3[1440:][self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.data.ugwt_mode3[1440:])[1])], 2)))

            lst.append("{:.2f}".format(round((self.Excel.FHMIN())[self.Excel.hmin().index(data_upper_lower_hmin(self.Excel.hmin(), self.Excel.FHMIN())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[0] == 0
            or data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw())[self.Excel.dm().index(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm())[self.Excel.dm().index(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[1] == 0
            or data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw())[self.Excel.dm().index(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugw())[1])], 2)))

            lst.append("{:.2f}".format(round((self.Excel.ugm())[self.Excel.dm().index(data_upper_lower_dm(self.Excel.dm(), self.Excel.ugm())[1])], 2)))

        return lst
    
    def angle_MN1(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM1())[self.Excel.PSUM1().index(max(self.Excel.PSUM1()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA1())[self.Excel.PSUM1().index(max(self.Excel.PSUM1()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode1[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[0])], 2)))

            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode2[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[0])], 2)))

            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode3[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[0])], 2)))

            lst.append("{:.2f}".format(round((self.Excel.FHMIN1())[self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode1[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode1[1440:])[1])], 2)))

            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode2[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode2[1440:])[1])], 2)))

            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt1_mode3[1440:][self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.data.ugwt1_mode3[1440:])[1])], 2)))

            lst.append("{:.2f}".format(round((self.Excel.FHMIN1())[self.Excel.hmin1().index(data_upper_lower_hmin(self.Excel.hmin1(), self.Excel.FHMIN1())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[0] == 0
            or data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw1())[self.Excel.dm1().index(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm1())[self.Excel.dm1().index(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[1] == 0
            or data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw1())[self.Excel.dm1().index(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugw1())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm1())[self.Excel.dm1().index(data_upper_lower_dm(self.Excel.dm1(), self.Excel.ugm1())[1])], 2)))

        return lst
    
    def angle_MN2(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM2())[self.Excel.PSUM2().index(max(self.Excel.PSUM2()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA2())[self.Excel.PSUM2().index(max(self.Excel.PSUM2()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode1[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode2[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode3[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN2())[self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[1])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode1[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode2[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt2_mode3[1440:][self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.data.ugwt2_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN2())[self.Excel.hmin2().index(data_upper_lower_hmin(self.Excel.hmin2(), self.Excel.FHMIN2())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[0] == 0
            or data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw2())[self.Excel.dm2().index(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm2())[self.Excel.dm2().index(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[1] == 0
            or data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw2())[self.Excel.dm2().index(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugw2())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm2())[self.Excel.dm2().index(data_upper_lower_dm(self.Excel.dm2(), self.Excel.ugm2())[1])], 2)))

        return lst
    
    def angle_MN3(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM3())[self.Excel.PSUM3().index(max(self.Excel.PSUM3()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA3())[self.Excel.PSUM3().index(max(self.Excel.PSUM3()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode1[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode2[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode2[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN3())[self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode1[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode2[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt3_mode3[1440:][self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.data.ugwt3_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN3())[self.Excel.hmin3().index(data_upper_lower_hmin(self.Excel.hmin3(), self.Excel.FHMIN3())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[0] == 0
            or data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw3())[self.Excel.dm3().index(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm3())[self.Excel.dm3().index(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[1] == 0
            or data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw3())[self.Excel.dm3().index(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugw3())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm3())[self.Excel.dm3().index(data_upper_lower_dm(self.Excel.dm3(), self.Excel.ugm3())[1])], 2)))

        return lst
    
    def angle_MN4(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM4())[self.Excel.PSUM4().index(max(self.Excel.PSUM4()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA4())[self.Excel.PSUM4().index(max(self.Excel.PSUM4()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode1[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode2[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode3[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN4())[self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode1[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode2[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt4_mode3[1440:][self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.data.ugwt4_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN4())[self.Excel.hmin4().index(data_upper_lower_hmin(self.Excel.hmin4(), self.Excel.FHMIN4())[1])], 2)))
        if (data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[0] == 0
            or data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw4())[self.Excel.dm4().index(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm4())[self.Excel.dm4().index(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[1] == 0
            or data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw4())[self.Excel.dm4().index(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugw4())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm4())[self.Excel.dm4().index(data_upper_lower_dm(self.Excel.dm4(), self.Excel.ugm4())[1])], 2)))

        return lst
        
    def angle_MN5(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM5())[self.Excel.PSUM5().index(max(self.Excel.PSUM5()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA5())[self.Excel.PSUM5().index(max(self.Excel.PSUM5()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode1[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode2[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode3[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN5())[self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode1[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode2[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt5_mode3[1440:][self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.data.ugwt5_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN5())[self.Excel.hmin5().index(data_upper_lower_hmin(self.Excel.hmin5(), self.Excel.FHMIN5())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[0] == 0
            or data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw5())[self.Excel.dm5().index(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm5())[self.Excel.dm5().index(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[1] == 0
            or data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw5())[self.Excel.dm5().index(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugw5())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm5())[self.Excel.dm5().index(data_upper_lower_dm(self.Excel.dm5(), self.Excel.ugm5())[1])], 2)))

        return lst
 
    def angle_MN6(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM6())[self.Excel.PSUM6().index(max(self.Excel.PSUM6()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA6())[self.Excel.PSUM6().index(max(self.Excel.PSUM6()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode1[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode2[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode3[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN6())[self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode1[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode2[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt6_mode3[1440:][self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.data.ugwt6_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN6())[self.Excel.hmin6().index(data_upper_lower_hmin(self.Excel.hmin6(), self.Excel.FHMIN6())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[0] == 0
            or data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw6())[self.Excel.dm6().index(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm6())[self.Excel.dm6().index(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[1] == 0
            or data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw6())[self.Excel.dm6().index(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugw6())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm6())[self.Excel.dm6().index(data_upper_lower_dm(self.Excel.dm6(), self.Excel.ugm6())[1])], 2)))

        return lst
 
    def angle_MN7(self):
        lst = []

        lst.append("{:.2f}".format(round((self.Excel.getGAM7())[self.Excel.PSUM7().index(max(self.Excel.PSUM7()))], 2)))
        lst.append("{:.2f}".format(round((self.Excel.getBETA7())[self.Excel.PSUM7().index(max(self.Excel.PSUM7()))], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[0] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[0]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[0]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[0]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode1[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[0])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode2[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[0])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode3[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN7())[self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[0])], 2)))

        if (data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[1] == 0
            or (self.mode == 1
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[1]))
            or (self.mode == 2
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[1]))
            or (self.mode == 3
                and not (data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[1]))
           ):
            lst.append('-')
            lst.append('-')
        else:
            if (self.mode == 1):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode1[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode1[1440:])[1])], 2)))
            elif (self.mode == 2):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode2[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode2[1440:])[1])], 2)))
            elif (self.mode == 3):
                lst.append("{:.2f}".format(round(self.data.ugwt7_mode3[1440:][self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.data.ugwt7_mode3[1440:])[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.FHMIN7())[self.Excel.hmin7().index(data_upper_lower_hmin(self.Excel.hmin7(), self.Excel.FHMIN7())[1])], 2)))

        if (data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[0] == 0
            or data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[0] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw7())[self.Excel.dm7().index(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[0])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm7())[self.Excel.dm7().index(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[0])], 2)))

        if (data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[1] == 0
            or data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[1] == 0):
            lst.append('-')
            lst.append('-')
        else:
            lst.append("{:.2f}".format(round((self.Excel.ugw7())[self.Excel.dm7().index(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugw7())[1])], 2)))
            lst.append("{:.2f}".format(round((self.Excel.ugm7())[self.Excel.dm7().index(data_upper_lower_dm(self.Excel.dm7(), self.Excel.ugm7())[1])], 2)))

        return lst
 
    def create_l3_v6_pdf(self):
        self.add_headers_from_second_block()
        self.add_2_row_in_main_block(self.data_row_BE(), self.data_BE(), self.angle_BE(), "{:.3f}".format(round(max(self.Excel.TN()), 3)), "BE")
        self.add_2_row_in_main_block(self.data_row_MN1(), self.data_MN1(), self.angle_MN1(), "{:.3f}".format(round(max(self.Excel.TN1()), 3)), "MN1")
        self.add_2_row_in_main_block(self.data_row_MN2(), self.data_MN2(), self.angle_MN2(), "{:.3f}".format(round(max(self.Excel.TN2()), 3)), "MN2")
        self.add_2_row_in_main_block(self.data_row_MN3(), self.data_MN3(), self.angle_MN3(), "{:.3f}".format(round(max(self.Excel.TN3()), 3)), "MN3")
        self.add_2_row_in_main_block(self.data_row_MN4(), self.data_MN4(), self.angle_MN4(), "{:.3f}".format(round(max(self.Excel.TN4()), 3)), "MN4")

    def create_l4_v8_pdf(self):
        self.create_l3_v6_pdf()
        self.add_2_row_in_main_block(self.data_row_MN5(), self.data_MN5(), self.angle_MN5(), "{:.3f}".format(round(max(self.Excel.TN5()), 3)), "MN5")

    def create_l6_v12_pdf(self):
        self.create_l4_v8_pdf()
        self.add_2_row_in_main_block(self.data_row_MN6(), self.data_MN6(), self.angle_MN6(), "{:.3f}".format(round(max(self.Excel.TN6()), 3)), "MN6")
        self.add_2_row_in_main_block(self.data_row_MN7(), self.data_MN7(), self.angle_MN7(), "{:.3f}".format(round(max(self.Excel.TN7()), 3)), "MN7")
        
# class Modes(PDF):
#     def __init__(self, path_to_res):
#         PDF.__init__(self, path_to_res)
#         self.excel = ReadExcel(path_to_res).getAllLists()
#         self.Excel = ReadExcel(path_to_res)
#         self.mode = path_to_res[9]
#         self.dict = {}
#         self.doc = QtGui.QTextDocument()
#         self.printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.PrinterResolution)
#         self.printer.setOutputFormat(QtPrintSupport.QPrinter.PdfFormat)
#         self.printer.setPaperSize(QtPrintSupport.QPrinter.A4)
#         self.printer.setOrientation(QtPrintSupport.QPrinter.Landscape)
#         self.html = """<html>
#                         <head>
#                             <style>
#                                 p{
#                                     font-size: 12px;
#                                     font-weight: 200;
#                                     color: black;
#                                 }
#                                 .title{
#                                     font-size: 15px;
#                                     text-align: center;
#                                     font-weight: 700;
#                                 }
                        
                        
#                                 .info{
#                                     margin: 20px;
#                                 }
                        
#                                 table {
#                                     margin: 3px;
#                                     font-size: 15px;
#                                     border-collapse:collapse;
#                                     width: 100%;
#                                 }

#                                 td {
#                                     border: 1px solid black;
#                                     text-align: center;
#                                     padding: 0px;
#                                 }
#                         </style>
#                         </head>
#                     """
#         self.html += f"""
#             <p class='title'>Режим {self.mode}</p>
#             <table>
#             """
#     def save(self, filename="data/mode.pdf"):
#         filename = f"data/mode{self.mode}.pdf"
#         self.html+="</table>"
#         self.printer.setOutputFileName(filename)
#         self.doc.setHtml(self.html)
#         self.doc.setPageSize(QtCore.QSizeF(self.printer.pageRect().size()))
#         self.doc.print_(self.printer)
        
 
    # def add_2_row_in_main_block(self, data_2_row_in_main_block):
    #     self.html += "<tr>"
    #     self.html += "<td>BE</td>"
    #     for i in range(len(data_2_row_in_main_block)):
    #         self.html += f"<td>{data_2_row_in_main_block[i]}</td>"
    #     self.html += "</tr>"
    
                    



                    
    
    


# # data_1_row: dict = {
# #     "ENGINE": "XXX",
# #     "FUEL": "XXX",
# #     "MAX CIL PRESSURE": "XXX",
# #     "APPLICATION":"XXX"
# # }

# # data_2_row: dict = {
# #     "VOL (L)": "XXX",
# #     "TYPE" : "XXX",
# #     "OIL SUPPLY PRESSURE (MPa)" : "XXX",
# #     "TURBO" : "XXX"
# # }

# # data_3_row: dict ={
# #     "SPEED (rpm)" : "xxx",
# #     "BORE (mm)" : "xxx",
# # } 

# # data_4_row: dict = {
# #     "FIRING" : "xxx"
# # }

# pdf = PDF("C:/Users/dimne/Downloads/Test/data_v12_res.xlsx")
# pdf.create_l6_v12_pdf()
# pdf.save()